﻿using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Base;
using SportsPlatform.Dto.SportBusiness.CompetitionGroupingInfo;
using SportsPlatform.Filters;
using SportsPlatform.Query.SportBusiness.CompetitionGroupingInfo;
using SportsPlatform.SportBusiness.ISportBusiness;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 比赛项目场次控制器
    /// </summary>

    [ActionAuthorization]
    [Route("api/[controller]/[action]")]
    public class CompetitionGroupingInfoController : SportsPlatformControllerBase
    {
        private ICompetitionGroupingInfoService _competitionGroupingInfoService;

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="competitionGroupingInfoService"></param>
        public CompetitionGroupingInfoController(ICompetitionGroupingInfoService competitionGroupingInfoService)
        {
            _competitionGroupingInfoService = competitionGroupingInfoService;
        }

        /// <summary>
        /// 新增比赛项目分组信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AddCompetitionGroupingInfo([FromBody] List<AddGroupInfoListsQuery> query)
        {
            return await _competitionGroupingInfoService.AddCompetitionGroupingInfo(query);
        }

        /// <summary>
        /// 分组信息同步
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> GroupingInfoSynchronization([FromBody] List<GroupingInfoSynchronizationQuery> query)
        {
            return await _competitionGroupingInfoService.GroupingInfoSynchronization(query);
        }

        /// <summary>
        /// 判断当前赛事项目是否存在分组信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<JudgeGroupinfoByEventsIdDto>> JudgeGroupinfoByEventsId([FromBody] JudgeGroupinfoByEventsIdQuery query)
        {
            return await _competitionGroupingInfoService.JudgeGroupinfoByEventsId(query);
        }

        /// <summary>
        /// 根据场次ID获取分组列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<GetGroupInfoListByEventSessionIdDto>> GetGroupInfoListByEventSessionId([FromBody] GetGroupInfoListByEventSessionIdQuery query)
        {
            return await _competitionGroupingInfoService.GetGroupInfoListByEventSessionId(query);
        }

        /// <summary>
        /// 获取第一场分组信息客户端
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultListDto<GetGroupCompeteInfoListDto>> GetGroupCompeteInfoList([FromBody] GetGroupCompeteInfoListQuery query)
        {
            return await _competitionGroupingInfoService.GetGroupCompeteInfoList(query);
        }
    }
}
